/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-10-09 19:07:16
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-09 19:16:08
 */
import java.util.Scanner;

public class Test01Login {
    public static void login(String username, String password) throws Exception{
        if(username.equals("roots")&&password.equals("bruip")){
            System.out.println("登录成功");
        }else{
            System.out.println("登录失败");
            //编译时异常
            throw new Exception("登录失败:用户名密码有误");
        }
    }

    public static void main(String[] args) throws Exception{
        //获取用户键盘输入
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名root");
        String name = sc.nextLine();
        System.out.println("请输入密码bruip");
        String password= sc.nextLine();
        login(name,password);
    }
}